<template>

  <div class="start_box">

    <div class="bread">
      <span>统计分析</span> >
      <span>盘点详情</span>
    </div>
    <div style="margin-top: 15px;">
      <h3>xxxx盘点详情</h3>
      <div>
        <el-table :data="detailData_pan" border style="width: 100%" :row-style="{height:50+'px'}">
          <el-table-column prop="facilityEncoding" label="编码" width="180">
          </el-table-column>
          <el-table-column prop="className" label="分类" width="180">
          </el-table-column>
          <el-table-column prop="facilityName" label="名称"> </el-table-column>
          <el-table-column prop="facilityAmount" label="库存数量">
          </el-table-column>
          <el-table-column prop="facilityPrice" label="单价（元）">
          </el-table-column>
          <el-table-column prop="actualCheckNum" label="实际盘点数">
            <template slot-scope="scope">
                    <el-input v-model="pan_" @input="changeNum(scope.$index, scope.row)"  placeholder="请输入实际盘点数" class="group-inp"></el-input>
            </template>           
          </el-table-column>
          <el-table-column  label="盘点-库存">
            <template slot-scope="scope" >
              {{ scope.row.facilityAmount-scope.row.actualCheckNum }}
            </template>
          </el-table-column>
          <el-table-column  label="盈亏值">
            <template slot-scope="scope">
              {{ (scope.row.facilityAmount-scope.row.actualCheckNum)*scope.row.facilityPrice }}
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top: 30px">
          <router-link to="/check">
              <el-button type="success" @click="finish_pan_btn" >完成盘点</el-button>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
// import { query } from "express";
import statistics_serive from "../../serive/statistics";
export default {
  name: "pan_start",
  data() {
    return {
      pan_:'',
      // 盘点详情列表
      detailData_pan: [],

    };
  },
  mounted() {
    console.log("id", this.$route.query.id);
    
    let id = this.$route.query.id;
    this.id = id
    // 修改状态
    statistics_serive.start_pan(id).then((res) => {
      // console.log('1',res.data.data);
    });
    // 盘点详情列表渲染
    statistics_serive.detail_pan(id, 50, 1).then((res) => {
      console.log("详情", res.data.data);
      this.detailData_pan = res.data.data;
    });
  },
  methods: {
    
    finish_pan_btn() {
      console.log(this.detailData_pan);
      console.log(this.id);
      statistics_serive.finish_pan(this.pan_,'',this.id).then((res) => {
        console.log(res.data.data);
    });
    },
    changeNum(a,b){
      console.log(a,b);
      console.log(this.pan_);
      console.log(this.detailData_pan);
      // b.actualCheckNum = this.pan_
      this.detailData_pan[a].actualCheckNum = this.pan_
      // this.$forceUpdate()
      // b.actualCheckNum = 
    }
  },
};
</script>
<style scoped> 
.start_box {
  overflow-y: auto;
  height: 600px;
  width: 100%;
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0px 20px 50px 0px rgba(191, 21, 108, 0.05);
}
.bread {
  margin-left: 20px;
  padding-top: 20px;
}
</style>